<?php if (!defined('CORE_DIR')) die('Wrong entry point!');

Aero::import('db/base/driver');
Aero::import('specs/db/MockDBResult');

Aero::define('MockDBDriver', AS_CLASS);

class MockDBDriver extends AeroDatabase
{
	protected $quote_open = '`';
	protected $quote_close = '`';
	
	public function insertId ()
	{
		return null;
	}

	public function affectedRows ()
	{
		return null;
	}

	public function escapeString ($string)
	{
		return addslashes($string);
	}

	protected function _query ($sql)
	{
		$this->sql = $sql;
		
		$ts = microtime(true);

		for ($i=0; $i < 100*rand(2,10); $i++)
		{ 
			//Do some work
			$v = sqrt($i*3);
		}

		AeroDatabase::$statistics[] = array(
			'query' => $sql,
			'time' => (microtime(true) - $ts)
		);

		return new MockDBResult($sql);
	}

	protected function _select ($name)
	{
		self::$selected_database = $name;
	}

	protected function _connect ($params)
	{

	}
}